/*
 * COPYRIGHT:	2010 Christopher Smith, licenced under the GNU GPL v2; see COPYING in the top level directory
 * PROJECT:		sdedit
 * FILE:		module.cpp
 * PURPOSE:		module support
 *				
 */

namespace Module
{

struct ModuleResourceDest
{
	virtual void BasicSidEnumerator(PCWSTR Name, Lookup::Enumerator<SID> *Enum) {}
	virtual void DomainSidEnumerator(Lookup::DomainAccountEnumerator *Enum) {}
	virtual void DomainEnumerator(PCWSTR Name, Lookup::DomainEnumerator *Enum) {}
	virtual void GuidTypeEnumerator(PCWSTR Name, Lookup::Enumerator<GUID> *Enum) {}
	virtual void GuidInhTypeEnumerator(PCWSTR Name, Lookup::Enumerator<GUID> *Enum) {}

	virtual void SidTranslator(PCWSTR Name, Lookup::Translator<SID> *Trn) {}
	virtual void GuidTypeTranslator(PCWSTR Name, Lookup::Translator<GUID> *Trn) {}
	virtual void GuidInhTypeTranslator(PCWSTR Name, Lookup::Translator<GUID> *Trn) {}

	virtual void Object(ObjectTypes::Object *Object) {}
};

typedef ULONG OPEN_STATUS;

static const ULONG OBJECT_NOTWANTED =		0x00000000; //ObjectWanted = FALSE, or unexpected early error
static const ULONG OBJECT_OPENED =			0x00000001; //object acutally opened and forwarded
static const ULONG OBJECT_NAME_INVALID =	0x00000002; //i.e. could never be opened
static const ULONG OBJECT_NAME_NOTFOUND =	0x00000003; //plausable but not found
static const ULONG OBJECT_OPEN_FAIL =		0x00000004; //found, but couldn't be opened for some other reason (e.g. access denied)
static const ULONG OBJECT_UNKNOWN_TYPE =	0x00000005; //the type in the generic opts is not supported by this module
static const ULONG OBJECT_OPEN_MASK =		0x000000FF;

static const ULONG COMPLETE_FAILURE =		0x00000100; //nothing could be opened
static const ULONG SECURITY_FAILURE =		0x00000200; //failure due to insufficient access
static const ULONG MODULE_IRRELEVANT =		0x00000400; //e.g. moudle not supported in this environment
static const ULONG TYPE_NOT_SUPPORTED =		0x00000800;

struct ModuleObject : auto_refctd_std_base
{
	virtual SDE_OPTS &ModuleOptions() = 0;
	virtual PCWSTR ModuleName() = 0;
	//virtual ObjectTypes::Object *TryOpenObject(SDE_GENERIC_OPTS const &GOpts, ModuleResourceDest &Res, UCHAR Privileges) = 0;
	//virtual void OpenResources(SDE_GENERIC_OPTS const &GOpts, ModuleResourceDest &Res) = 0;

	virtual void OpenResources(OPEN_STATUS &OpenStatus, SDE_GENERIC_OPTS const &GOpts, ModuleResourceDest &Res, UCHAR Privileges, BOOLEAN ObjectWanted) = 0;
	//status of open, generic options, target to pass on module resources, privileges availaible for use, is call focused on opening an actual secured object
	//note that exceptions could also be raised instead of a normal return. some resources may already be returned (and can be used)
	//OpenStatus should be initialized to 0 and will contain valid status on return, even in the event of an exception
	//if ObjectWanted = TRUE then OPEN_STATUS should be filled in with the status of opening the objcet

	virtual ~ModuleObject()
	{}
};

}//namespace Module) 